﻿@using FlowBasisSampleSite.Domain.Entities
@{
    ViewBag.Title = "Info";

    UserAccount userAccount = ViewBag.UserAccount;
}

@Html.Partial("Partials/UserAccountInfo", userAccount)

<div>
@if (userAccount.IsDeleted)
{
    <a href='javascript:;' onclick='undeleteUser();'>Undelete Account</a>
}
else
{
    <a href='javascript:;' onclick='deleteUser();'>Delete Account</a>
}
</div>

<script type="text/javascript">

    function undeleteUser() {
        FlowBasis.Rpc.invokeAndWait(
            "~/Admin/UserAccounts/UndeleteUserAccount",
            { id: @userAccount.UserAccountId },
            function (response, success) {
                if (success) {
                    window.location.reload();
                }
            }
        );
    }

    function deleteUser() {
        FlowBasis.Rpc.invokeAndWait(
            "~/Admin/UserAccounts/DeleteUserAccount",
            { id: @userAccount.UserAccountId },
            function (response, success) {
                if (success) {
                    window.location.reload();
                }
            }
        );
    }

</script>